package com.xinruke.hostels.central.manage.controller;

import com.xinruke.hostels.central.manage.interfaces.dto.*;
import com.xinruke.hostels.central.manage.service.HotelInfoService;
import com.xinruke.hostels.common.cache.ManageUserCache;
import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.po.YwJiudian;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName HotelInfoController
 * @CreateDate 2019/6/13
 * @Author FengXinQiang
 * @Version V1.0.0.0
 * @Decription 酒店信息
 */
@RestController
@RequestMapping("hotel/info")
@Api(tags = "酒店信息")
public class HotelInfoController extends BaseController {

    @Resource
    private HotelInfoService hotelInfoService;

    @Resource
    private ManageUserCache manageUserCache;

    @PostMapping("/add")
    @ApiOperation("添加酒店信息")
    public ResultVO addHotelInfo(@RequestBody @Valid HotelInfoAddDTO hotelInfoAddDTO) {
        return hotelInfoService.addHotelInfo(hotelInfoAddDTO);
    }

    @PostMapping("/modify")
    @ApiOperation("修改酒店信息")
    public ResultVO modifyHotelInfo(@Valid @RequestBody HotelInfoModifyDTO hotelInfoModifyDTO) {
        return hotelInfoService.modifyHotelInfo(hotelInfoModifyDTO);
    }

    @PostMapping("/del")
    @ApiOperation("删除酒店")
    public ResultVO delHotel(@Valid @RequestBody HotelInfoDelDTO hotelInfoModifyDTO) {
        return hotelInfoService.delHotel(hotelInfoModifyDTO);
    }

    @PostMapping("/personal/list")
    @ApiOperation(value = "预订系统下个人预订酒店查询")
    public ResultVO<RowsDataVO<HotelPersonalQueryResultDTO>> getPersonalHotelInfoList(@RequestBody HotelPersonalQueryDTO hotelInfoQueryDTO) {
        ResultVO<RowsDataVO<HotelPersonalQueryResultDTO>> resultVO = ResultVO.fail();
        RowsDataVO<HotelPersonalQueryResultDTO> dataVO = hotelInfoService.getPersonalHotelInfoList(hotelInfoQueryDTO);
        resultVO.setCode(ResultVO.SUCCESS);
        resultVO.setMessage("操作成功");
        resultVO.setData(dataVO);
        return resultVO;
    }

    @PostMapping("/meeting/list")
    @ApiOperation(value = "预订系统下会议预订酒店查询")
    public ResultVO<RowsDataVO<HotelMeetingQueryResultDTO>> getMeetingHotelInfoList(@RequestBody HotelMeetingQueryDTO hotelInfoQueryDTO) {
        ResultVO<RowsDataVO<HotelMeetingQueryResultDTO>> resultVO = ResultVO.fail();
        RowsDataVO<HotelMeetingQueryResultDTO> dataVO = hotelInfoService.getMeetingHotelInfoList(hotelInfoQueryDTO);
        resultVO.setCode(ResultVO.SUCCESS);
        resultVO.setMessage("操作成功");
        resultVO.setData(dataVO);
        return resultVO;
    }

    /**
     * 中央决策使用酒店列表
     *
     * @return
     */
    @PostMapping("central/list")
    @ApiOperation(value = "中央决策使用酒店列表")
    public ResultVO<RowsDataVO<HotelCentralQueryResultDTO>> getHotelCentralInfoList(@RequestBody HotelCentralQueryDTO hotelCentralQueryDTO) {
        return hotelInfoService.getHotelCentralInfoList(hotelCentralQueryDTO);
    }

    /**
     * 提供展示所有酒店列表，不分页，
     *
     * @return
     */
    @PostMapping("/all/list")
    @ApiOperation(value = "查询所有酒店下拉框")
    public ResultVO<List<HotelAllQueryResultDto>> getAllHotelList(@RequestBody HotelAllQueryDTO allQueryDTO) {
        return hotelInfoService.getAllHotelList(allQueryDTO);
    }

    /**
     * 提供展示所有酒店列表，不分页，
     *
     * @return
     */
    @PostMapping("/pms/list")
    @ApiOperation(value = "pms酒店列表")
    public ResultVO<RowsDataVO<HotelCentralQueryResultDTO>> getPMSHotelList(@RequestBody HotelPMSQueryDTO allQueryDTO) {
        return hotelInfoService.getPMSHotelList(allQueryDTO);
    }

    /**
     * 查询所有酒店
     *
     * @return
     */
    @PostMapping("/all")
    @ApiIgnore
    public List<YwJiudian> getAllHotel(@RequestBody HotelAllQueryDTO allQueryDTO) {

        return hotelInfoService.getAllHotel(allQueryDTO);
    }

    /**
     * 酒店详情
     * 1.图片信息
     * 2.显示酒店的基本信息
     * 2.1.名称、地址、联系人、联系人电话，以及地图图片
     * 2.2联系方式（前台军线电话、前台地方电话、预订联系人、预订联系人电话）、单位简介、地理区位、其他服务、配套设施、退房时间（采用24小时制显示）。
     * 3.客房列表、会场列表、餐厅列表、点评四个页签
     *
     * @return
     */
    @PostMapping("/detail")
    @ApiOperation(value = "酒店详情")
    public ResultVO<HotelInfoDetailQueryResultDTO> getHotelInfoDtail(@RequestBody HotelInfoDetailQueryDTO hotelDetailQueryDTO) {
        ResultVO<HotelInfoDetailQueryResultDTO> resultVO = ResultVO.fail();
        HotelInfoDetailQueryResultDTO data = hotelInfoService.getHotelInfoDtail(hotelDetailQueryDTO);
        if (data != null) {
            resultVO.setCode(ResultVO.SUCCESS);
            resultVO.setMessage("操作成功");
            resultVO.setData(data);
        }

        return resultVO;
    }

    @PostMapping("/pms/detail")
    @ApiOperation(value = "酒店详情")
    public ResultVO<HotelInfoDetailQueryResultDTO> getPMSHotelInfoDtail(@RequestBody HotelInfoDetailQueryDTO hotelDetailQueryDTO) {
        hotelDetailQueryDTO.setId(manageUserCache.getJiudianId());
        ResultVO<HotelInfoDetailQueryResultDTO> resultVO = ResultVO.fail();
        HotelInfoDetailQueryResultDTO data = hotelInfoService.getHotelInfoDtail(hotelDetailQueryDTO);
        if (data != null) {
            resultVO.setCode(ResultVO.SUCCESS);
            resultVO.setMessage("操作成功");
            resultVO.setData(data);
        }

        return resultVO;
    }
}
